package com.bice.controller.entity;

import com.bice.controller.dao.IEntity;
import java.util.List;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.*;

/**
 * 
 * @author Sirius
 */
@Entity
@Table(name="biceUser")
public class BiceUser  implements IEntity {
    
    private Integer id;
    private String code;
    private String nickname;
    private String password;
    private byte[] image;
    private List<Post> postsFrom;
    private List<Post> postsTo;
    
    public BiceUser() {
    }
	
    public BiceUser(String nickname) {
        this.nickname = nickname;
    }
    
    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="id", unique=true, nullable=false)
    @Override
    public Integer getId() {
        return this.id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    @Column(name="code", nullable=false, length=32)
    @Override
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
    
    @Column(name="nickname", nullable=false, length=16)
    public String getNickname() {
        return this.nickname;
    }
    
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
    
    @Column(name="password", nullable=false, length=32)
    public String getPassword() {
        return this.password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }
 
    @Lob
    @Column(name="image")
    public byte[] getImage() {
        return this.image;
    }
    
    public void setImage(byte[] image) {
        this.image = image;
    }

    @OneToMany(mappedBy = "from")
    public List<Post> getPostsFrom() {
        return postsFrom;
    }

    public void setPostsFrom(List<Post> postsFrom) {
        this.postsFrom = postsFrom;
    }

    @OneToMany(mappedBy = "to")
    public List<Post> getPostsTo() {
        return postsTo;
    }

    public void setPostsTo(List<Post> postsTo) {
        this.postsTo = postsTo;
    }
    
}